<?php
require './function.php';
/**
 * @Author: Wherein
 * @Date: 2021-03-30 15:52
 * @Descripttion: 代理模式
 * @example 唱片例子
 */

interface Shop
{
    public function buy($title);
}

/**
 * CD商店
 *
 * @date 2021-03-30 15:56
 */
class CDshop implements Shop
{
    public function buy($title)
    {
        dd('购买成功,这是你的' . $title . '唱片');
    }
}

/**
 * 代理CD
 *
 * @date 2021-03-30 15:56
 */
class Proxy implements Shop
{
    public function buy($title)
    {
        $this->go();
        $CDshop = new CDshop();
        $CDshop->buy($title);
    }

    public function go()
    {
        dd('跑去香港代购');
    }
}

$CDshop = new CDshop();
$CDshop->buy('不要认输');

$proxy = new Proxy();
$proxy->buy('25周年纪念');